package org.come.mouslisten;

import org.come.Frame.ZhuFrame;
import org.come.Jpanel.DepositListJpanel;
import org.come.gltools.RendererTools;
import org.come.until.FormsManagement;
import org.come.until.UserMessUntil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class PetDepositJlistChoseMouslisten implements MouseListener, MouseMotionListener {
    private JList<String> listpet;// 召唤兽列表选中框

    private DepositListJpanel testPetJpanel;// 宠物面板

    public PetDepositJlistChoseMouslisten(JList<String> listpet, DepositListJpanel testPetJpanel) {
        this.listpet = listpet;

        this.testPetJpanel = testPetJpanel;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
        // 打开了窗体
        if (e.isMetaDown()) {// 检测鼠标右键单击
            FormsManagement.HideForm(6);
        }
    }

    @Override
    public void mousePressed(MouseEvent e) {


    }

    @Override
    public void mouseReleased(MouseEvent e) {
        // TODO Auto-generated method stub
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub
    }

    @Override
    public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub
        ZhuFrame.getZhuJpanel().pettext();
    }

    @Override
    public void mouseDragged(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseMoved(MouseEvent e) {
        if (e.getY() / 20 < listpet.getModel().getSize()) {
            int idx = listpet.locationToIndex( e.getPoint());
            listpet.setCellRenderer(new RendererTools(idx, new Color(135,135,135,100)));
            ZhuFrame.getZhuJpanel().creatpettext(UserMessUntil.getDepositPetListTable().get(idx));
        }else{
            ZhuFrame.getZhuJpanel().pettext();
        }

    }

}
